package com.example.chdemo.Service.Impl;

import com.example.chdemo.Dao.Person;
import com.example.chdemo.Mapper.PersonMapper;
import com.example.chdemo.Service.PersonService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {

    @Autowired
    PersonMapper personMapper;

    @Override
    public List<Person> getList(){
        return personMapper.getList();
    }

    @Override
    public Person getOne(Integer id){
        return personMapper.getOne(id);
    }

    @Override
    public int insert(Person person){
        return personMapper.insert(person);
    }

    @Override
    public int del(Integer id){
        return personMapper.del(id);
    }

    @Override
    public int upData(Person person){
        return personMapper.upData(person);
    }

    @Override
    public PageInfo<Person> getAllPage(Integer pageNum,Integer pageSize){
        Page<Object> objects = PageHelper.startPage(pageNum,pageSize);
        List<Person> people = personMapper.getList();
        return new PageInfo<>(people);
    }
}
